package com.example.lab03.controller;

import com.example.lab03.entity.User;
import com.example.lab03.service.UserService;
import com.fasterxml.jackson.databind.ser.Serializers;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("user")
public class UserController {
    private final UserService userService;

    public UserController(UserService userService) {
        this.userService = userService;
    }

    @GetMapping("queryAll")
    private List<User> queryAll() {
        return userService.queryAll();
    }

    //创建等于发送数据 post请求
    @PostMapping("create")
    private User create(@RequestBody User user) {
        return userService.create(user);
    }

    @GetMapping("queryById/{id}")
    private User queryById(@PathVariable String id) {
        return userService.queryById(id);
    }

    @PutMapping("modify")
    private User modify(@RequestBody User user) {
        return userService.modify(user);
    }

    @DeleteMapping("removeById/{id}")
    private String removeById(@PathVariable String id) {
        return userService.removeById(id);
    }
}
